K Framework - Installation and Basic Usage for Smart Contract Formal Verification


Slide 1: What is K Framework?


Slide 2: Why Use K Framework for Smart Contracts?


Slide 3: Installing K Framework

  1. Pre-requisites:

    • Ubuntu (or any Linux distro)
    • Java 8 or later
    • Haskell
    • Z3 Theorem Prover (optional but recommended for formal verification)
  2. Installation Steps:

    1. Install Binaries from:
      https://github.com/runtimeverification/k/releases/tag/v7.1.155

    2. Verify Installation:

      • Check by running the command:
        kompile --version
        

Slide 4: K Framework Basics


Slide 5: Formal Verification Using K


Slide 6: Example Smart Contract: Token Transfer


Slide 7: Formalizing the Token Contract in K


Slide 8: Running Formal Verification

  1. Compile the Contract:

    kompile contract.k
    
  2. Prove Properties:

    krun --prove contract-verification-spec.k
    
  3. Output:

    • If the proof is successful, K Framework confirms that the smart contract satisfies all the specified properties.